﻿@{
    var F = Html.F();

    var _bodyClass = "";
    if (ViewBag.BodyBGColor != null)
    {
        _bodyClass = "f-body-bgcolor";
    }
}

<!DOCTYPE html>
<html>
<head>
    <title>@Html.Raw(ViewBag.Title)</title>
    @if (ViewBag.SourceFiles != null)
    {
        <meta name="sourcefiles" content="@ViewBag.SourceFiles" />
    }

    @F.RenderCss()

    <link href="~/res/css/common.css?v@(GlobalConfig.ProductVersion)" rel="stylesheet" type="text/css" />
    @RenderSection("head", false)
    
</head>
<body class="@_bodyClass">

    @Html.AntiForgeryToken()

    @{
        var pm = F.PageManager;

        // 主题
        var themeCookie = Context.Request.Cookies["Theme"];
        if (!String.IsNullOrEmpty(themeCookie))
        {
            Theme theme;
            if (Enum.TryParse<Theme>(themeCookie, true, out theme))
            {
                // 先清空CustomTheme，再设置Theme
                pm.CustomTheme(String.Empty);
                pm.Theme(theme);
            }
            else
            {
                pm.CustomTheme(themeCookie);
            }
        }

        // 语言
        var langCookie = Context.Request.Cookies["Language"];
        if (!String.IsNullOrEmpty(langCookie))
        {
            Language lang;
            if (Enum.TryParse<Language>(langCookie, true, out lang))
            {
                pm.Language(lang);
            }
            else
            {
                pm.CustomLanguage(langCookie);
            }
        }

        // 加载动画
        var loadingCookie = Context.Request.Cookies["Loading"];
        if (!String.IsNullOrEmpty(loadingCookie))
        {
            int loadingNumber = Convert.ToInt32(loadingCookie);
            pm.LoadingImageNumber(loadingNumber);
        }


        pm.MobileAdaption(false);
        pm.DisplayMode(FineUICore.DisplayMode.Normal);
        pm.EnableAnimation(false);
    }
    @F.PageManager

    @RenderSection("body", true)

    @F.RenderScript()

    <script type="text/javascript" src="~/res/js/common.js?v@(GlobalConfig.ProductVersion)"></script>
    @RenderSection("script", false)
</body>
</html>